Skip to content

Conversation

@josh-padnick
Copy link
Contributor

@josh-padnick josh-padnick commented Aug 15, 2025

Description

Update https://terragrunt-v1.gruntwork.io/docs/features/hooks/ to clarify that hooks give you control over exit codes. I learned about this today and couldn't find it in the docs, so hopefully this will be helpful to others!

TODOs

Read the Gruntwork contribution guidelines.

  • I authored this code entirely myself
  • I am submitting code based on open source software (e.g. MIT, MPL-2.0, Apache)]
  • I am adding or upgrading a dependency or adapted code and confirm it has a compatible open source license
  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added docs on hook exit codes

Summary by CodeRabbit

  • Documentation
    • Added a “Hook exit codes” section to the Hooks documentation, detailing how non-zero exit codes from before_hook or after_hook propagate to the overall Terragrunt exit code.
    • Included an example showing that a failing after_hook results in a non-zero exit code even if tofu/terraform completes successfully, improving clarity on expected behavior.

@vercel
Copy link

vercel bot commented Aug 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
terragrunt-docs Ready Ready Preview Comment Aug 15, 2025 8:13pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 15, 2025

📝 Walkthrough

Walkthrough

Adds a new "Hook exit codes" section to the Hooks documentation explaining that non-zero exit codes from before_hook/after_hook propagate to Terragrunt’s exit code, with an example. The section is inserted twice (duplicated). No code or public API changes.

Changes

Cohort / File(s) Summary
Docs: Hooks exit codes
docs-starlight/src/content/docs/02-features/10-hooks.md
Added “Hook exit codes” section describing propagation of non-zero exit codes from before_hook/after_hook; includes example. Content inserted twice (duplicate). No code/API changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch josh-padnick-patch-1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
docs-starlight/src/content/docs/02-features/10-hooks.md (5)

232-236: Polish the “Hook exit codes” section: fix typos and tighten phrasing

  • Replace “apply more control to” with “control”/“gain more control over.”
  • Fix “after-hook” → “after_hook.”
  • Remove the stray “the” and extra backtick.
  • Avoid “unit” (undefined term here); use “configuration” (or “module/directory”) for clarity.
-Hooks allow you to apply more control to the exit code returned by the applicable underlying OpenTofu/Terraform command. If any `before_hook` or `after_hook` returns a non-zero exit code, the Terragrunt command you run against the unit will return a non-zero exit code.
+Hooks let you control Terragrunt's exit code. If any `before_hook` or `after_hook` returns a non-zero exit code, the Terragrunt command will exit non-zero.

-For example, suppose you run `terragrunt apply` on a given unit that has no `before_hook`, but has a non-empty `after-hook`. Because there is no `before_hook` defined, Terragrunt will first run `tofu apply`, and let's assume that succeeds and returns an exit code of `0`. Next, Terragrunt will run your `after_hook`. If that fails and returns an exit code of `1`, the ` the entire `terragrunt apply` operation will return an exit code of `1`, even though the underlying `tofu apply` succeeded.
+For example, suppose you run `terragrunt apply` in a configuration that defines no `before_hook` but does define an `after_hook`. Terragrunt will first run `tofu apply` (assume it succeeds and returns `0`). Next, Terragrunt runs the `after_hook`. If that hook fails and returns `1`, the overall `terragrunt apply` command will also return `1`, even though `tofu apply` succeeded.

9-11: Capitalize “Terragrunt” and fix article usage

Minor grammar/consistency nits.

-_Before Hooks_, _After Hooks_ and _Error Hooks_ are a feature of terragrunt that make it possible to define custom actions that will be called before/after running an `tofu`/`terraform` command.
+_Before Hooks_, _After Hooks_, and _Error Hooks_ are a feature of Terragrunt that make it possible to define custom actions that will be called before/after running a `tofu`/`terraform` command.

132-136: Smoother wording

Tighten the sentence and clarify “related to running OpenTofu/Terraform.”

-Hooks can be used to handle operations that need to happen, but are not directly related to the OpenTofu/Terraform.
+Hooks can handle operations that need to happen but are not directly related to running OpenTofu/Terraform.

209-211: Subject–verb agreement and concision

“Each hook … they are” mismatch; also simplify phrasing.

-You can have multiple before and after hooks. Each hook will execute in the order they are defined.
+You can define multiple before and after hooks. Each hook executes in the order it is defined.

255-257: Fix possessive “its” and parallelism

Also capitalize the product name consistently in the link text if you prefer.

-The `.tflint.hcl` should exist in the same folder as `terragrunt.hcl` or one of it's parents. If Terragrunt can't find
-a `.tflint.hcl` file, it won't execute tflint and return an error. All configurations should be in a `config` block in this
-file, as per [Tflint's docs](https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md).
+The `.tflint.hcl` should exist in the same folder as `terragrunt.hcl` or one of its parents. If Terragrunt can't find
+a `.tflint.hcl` file, it won't execute tflint and will return an error. All configurations should be in a `config` block in this
+file, as per [TFLint's docs](https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md).
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6f4719b and 5d36705.

📒 Files selected for processing (1)
  • docs-starlight/src/content/docs/02-features/10-hooks.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
docs-starlight/**/*.md*

⚙️ CodeRabbit Configuration File

Review the documentation for clarity, grammar, and spelling. Make sure that the documentation is easy to understand and follow. There is currently a migration underway from the Jekyll based documentation in docs to the Starlight + Astro based documentation in docs-starlight. Make sure that the docs-starlight documentation is accurate and up-to-date with the docs documentation, and that any difference between them results in an improvement in the docs-starlight documentation.

Files:

  • docs-starlight/src/content/docs/02-features/10-hooks.md
🪛 LanguageTool
docs-starlight/src/content/docs/02-features/10-hooks.md

[grammar] ~236-~236: There might be a mistake here.
Context: ...ls and returns an exit code of 1, the the entireterragrunt apply` operation wil...

(QB_NEW_EN)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: build_no_proxy / Build (windows/386)
  • GitHub Check: build_no_proxy / Build (darwin/arm64)
  • GitHub Check: build_no_proxy / Build (windows/amd64)
  • GitHub Check: build_no_proxy / Build (linux/arm64)
  • GitHub Check: build_no_proxy / Build (darwin/amd64)
  • GitHub Check: build_no_proxy / Build (linux/amd64)
  • GitHub Check: build_no_proxy / Build (linux/386)
  • GitHub Check: build / Build (darwin/amd64)
  • GitHub Check: build / Build (linux/386)
  • GitHub Check: build / Build (windows/386)
  • GitHub Check: build / Build (darwin/arm64)
  • GitHub Check: build / Build (linux/amd64)
  • GitHub Check: build / Build (linux/arm64)
  • GitHub Check: base_tests / Test (macos)
  • GitHub Check: base_tests / Test (ubuntu)
  • GitHub Check: build-and-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants